﻿using CommunityToolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EC3_6CLH.Model
{
    public partial class DiDoStatus : ObservableObject
    {
        public Action<object, bool, bool>? StatusChanged;

        partial void OnStatusChanged(bool oldValue, bool newValue)
        {
            StatusChanged?.Invoke(this, oldValue, newValue);
        }

        [ObservableProperty] private string _description = string.Empty;

        [ObservableProperty] private bool _isDo;

        [ObservableProperty]
        private int _channelIndex;

        [ObservableProperty]
        private bool _status;

        public string DisplayText => $"{Description}[{ChannelIndex}]";

        public bool IsUpdatingFromBackend { get; private set; }

        public void SetStatusFromBackend(bool value)
        {
            IsUpdatingFromBackend = true;
            Status = value;
            IsUpdatingFromBackend = false;
        }
    }
}